package cn.tedu.boot06.controller;

import cn.tedu.boot06.entity.Product;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author 作者：HeShaoShuai
 * @Email 邮箱：2569819541@qq.com
 * @Date 日期：2023/5/12 10:14
 * @Package 包名：cn.tedu.boot06.controller
 * @Project 项目名：JavaSE
 * @Version 1.0
 */
@RestController
public class AxiosController {
	@RequestMapping("/helloAxios")
	public String helloAxios(String name,int age){

		return "测试成功!"+name+":"+age;
	}
	//如果是异步请求并且提交的参数是自定义的js对象,服务器接收参数时必须添加@RequestBody注解
	//否则接收不到参数
	@RequestMapping("/postAxios")
	public String postAxios(@RequestBody Product product){
		System.out.println("product = " + product);
		return "post请求成功!";
	}
}